package com.example.riseofthedefender;

import java.util.ArrayList;

import javax.microedition.khronos.opengles.GL10;

public class Ball extends Square{
	
	public static int current = 0;
	public static ArrayList<Ball> arrayList;
	public static void initArrayList(int size)
	{
		arrayList = new ArrayList<Ball>(size);
		for(int i = 0; i < size; ++i)
			arrayList.add(new Ball());
	}
	public static int getNext()
	{
		++current;
		if(current >= arrayList.size())
			current = 0;
		return current;
	}
	
	public Ball()
	{
		wHlv = 20.0f;
		hHlv = 20.0f;
	}
	
	public void update()
	{
		pos.y -= 4.0f;
		if(pos.y < Camera.boundS - GameVar.cHeightH)
			pos.y = Camera.boundN + GameVar.cHeightH;
	}
	
	public void draw(GL10 gl) {
		if(pos.x-wHlv>Camera.east || pos.x+wHlv<Camera.west || pos.y+hHlv< Camera.south || pos.y-hHlv > Camera.north)
			return;
		gl.glLoadIdentity();
		gl.glTranslatef(-Camera.pos.x,-Camera.pos.y,0.0f);
		gl.glTranslatef(pos.x, pos.y, 0.0f);
		gl.glBindTexture(GL10.GL_TEXTURE_2D, TextureManager.BALL.textures[0]);
		gl.glScalef(wHlv, hHlv, 1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
	}
}
